package com.example.hhhh;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.alibaba.android.arouter.facade.annotation.Route;

/**
 * @ProjectName: Hhhh
 * @Package: com.example.hhhh
 * @ClassName: EighthAct
 * @Description: java类作用描述
 * @Author: songhua
 * @CreateDate: 2020/4/8 0008 14:11
 */
@Route(path = "/app/TenthAct")
public class TenthAct extends SwipeBackActivity implements View.OnClickListener {
    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tenth);
        btn= (Button) findViewById(R.id.btn);

        btn.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        if (checkCameraHardWare(getApplicationContext())){
            Intent intent = new Intent(getApplicationContext(), MyCameraActivity.class);
            startActivity(intent);
        }else{
            Toast.makeText(getApplicationContext(), "没有相机存在", Toast.LENGTH_SHORT).show();
        }


    }

        /**
         * 检测相机设备是否存在：
         * */
    private boolean checkCameraHardWare(Context context) {
        PackageManager packageManager = context.getPackageManager();
        if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
            return true;
        }
        return false;
    }



}
